<template>
  <div class="header">
    <div class="content-wrapper">
      <div class="avatar">
        <img :src="seller.avatar" alt="">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span> 
        </div>
        <div class="description">
          {{seller.description}}&nbsp;/&nbsp;{{seller.deliveryTime}}分钟送达
        </div>
        <div v-if="seller.supports" class="support">
          <span class="icon" :class='classMap[seller.supports[0].type]'></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>        
      </div>
      <div v-if='seller.supports' class="supports-count" @click="showMoreDetail">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper">
      <span class="bulletin-title"></span><span class="bulletin-text">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>        
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%">
    </div>
    <!-- 详细内容（弹窗） -->
    <div class="detail" v-show="detailShow">
      <div class="detail-wrapper clearfix">
        <div class="detail-main">
          <div class="name">{{ seller.name }}</div>
          <div class="star-wrapper">
            <stars class="star" :score="seller.score" :size="48"></stars>
          </div>
          <div class="supports-list">
            <subhead class="subhead" :subhead="'优惠信息'"></subhead>
            <ul class="allSupport" v-if="seller.supports">
              <li class="support-item" v-for="(item, i) in seller.supports" :key="i">
                <span class="icon-detail" :class="classMap[item.type]"></span>
                <span class="text-detail"> {{ item.description }} </span>           
              </li>
            </ul>
          </div>
          <div class="seller-bulletin">
            <subhead class="subhead" :subhead="'商家公告'"></subhead>
            <p class="content">{{seller.bulletin}}</p>
          </div>
        </div>
      </div>
      <div class="detail-close linclass" @click="closeMoreDetail">
        <i class="icon-close"></i>
      </div>
    </div>
  </div>
</template>
<script>
import stars from 'components/stars/stars.vue'
import subhead from './subhead.vue'
export default {
  name: 'v-header',
  // props: ['seller'],
  props: {
    seller: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data () {
    return {
      classMap: ['decrease', 'discount', 'special', 'invoice', 'guarantee'],
      detailShow: false 
    }
  },
  methods: {
    showMoreDetail() {
      this.detailShow = true
    },
    closeMoreDetail() {
      this.detailShow = false
    }
  },
  components: {
    stars,
    subhead
  }
}
</script>
<style lang="stylus" scoped>
@import '../../common/stylus/mixin'
.header
  position relative
  overflow hidden
  color: #fff
  background: rgba(7,17,27,0.5)
  .content-wrapper
    position: relative
    padding: 24px 12px 18px 24px
    font-size: 0
    .avatar
      display: inline-block
      vertical-align: top
      img
        width: 64px
        height: 64px
        border-radius: 2px
    .content
      display: inline-block
      margin-left: 16px
      .title
        margin: 2px 0 8px 0
        .brand
          display: inline-block
          vertical-align: top
          width: 30px
          height: 18px
          bg-image('brand')
          background-size: 30px 18px
          background-repeat: no-repeat
        .name
          margin-left: 6px
          line-height: 18px
          font-size: 16px
          font-weight: bold
      .description
        font-size: 12px
        line-height: 12px
        margin-bottom: 10px
      .support
        .icon
          vertical-align: top
          display: inline-block
          width: 12px
          height: 12px
          background-size: 12px 12px
          background-repeat: no-repeat
          &.decrease
            bg-image('decrease_1')
          &.discount
            bg-image('discount_1')
          &.guarantee
            bg-image('guarantee_1')
          &.invoice
            bg-image('invoice_1')
          &.special
            bg-image('special_1')
        .text
          margin-left: 4px
          line-height: 12px
          font-size: 10px
    .supports-count
      position: absolute
      bottom: 18px
      right: 12px
      height 24px
      padding: 0 8px
      background-color: rgba(0,0,0,0.2)
      border-radius: 14px      
      font-size: 10px
      text-align: center
      .count
        vertical-align: middle
        margin-right: 2px
        line-height: 24px
      .icon-keyboard_arrow_right
        line-height: 24px
  .bulletin-wrapper
    position relative
    height 28px
    // line-height 28px
    // width 100%
    padding 0 22px 0 12px
    white-space nowrap
    overflow hidden
    text-overflow ellipsis
    background rgba(7,17,27,0.2)
    .bulletin-title
      display inline-block
      vertical-align top
      margin-top 8px
      height 12px
      width 22px
      bg-image('bulletin')
      background-size 22px 12px
      background-repeat no-repeat
    .bulletin-text
      vertical-align top
      margin 0 4px
      font-size 10px
      line-height 28px
    .icon-keyboard_arrow_right
      position absolute
      top 0
      right 12px
      font-size 10px
      line-height 28px
  .background
    position absolute
    top 0
    left 0
    width 100%
    height 100%
    z-index -1
    filter blur(10px)
  .detail
    position fixed
    top 0
    left 0
    width 100%
    height 100%
    background-color rgba(7,17,27,0.8)
    z-index 99
    overflow auto
    .detail-wrapper
      width 100%
      min-height 100%
      color #fff
      .detail-main
        margin-top 64px
        padding-bottom 64px
        .name
          font-size 16px
          font-weight 700
          line-height 16px
          text-align center
        .star-wrapper
          width 100%
          margin-top 16px
          text-align center
        .supports-list
          .allSupport
            margin 0 36px
            .support-item
              margin-bottom 12px
              padding 0 12px
              font-size 0
              &:last-child
                margin-bottom 0
              .icon-detail
                display: inline-block
                vertical-align: top
                width: 16px
                height: 16px
                background-size: 16px 16px
                background-repeat: no-repeat
                &.decrease
                  bg-image('decrease_1')
                &.discount
                  bg-image('discount_1')
                &.guarantee
                  bg-image('guarantee_1')
                &.invoice
                  bg-image('invoice_1')
                &.special
                  bg-image('special_1')
              .text-detail
                margin-left 6px
                font-size 12px
                line-height 16px
        .seller-bulletin
          .content
            padding 0 48px
            font-size 12px
            line-height 24px

    .detail-close
      position relative
      width 32px
      height 32px
      margin -64px auto 0 auto 
      clear both
      font-size 32px
</style>
